package com.umakr.ax.app.web;

import com.umakr.ax.app.service.AppSmsService;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author umakr
 */
@Controller
@RequestMapping("/api/sms")
public class SmsAppController extends AbstractController {

    @Autowired
    AppSmsService appSmsService;

    @ApiOperation(value = "发送验证码")
    @GetMapping("/sendPhoneVerifyCode")
    @ResponseBody
    public Object sendPhoneVerifyCode(ModelMap modelMap, @RequestParam(name = "phone") String phone,Integer type) {
        return setSuccessModelMap(modelMap,appSmsService.sendPhoneVerifyCode(phone,type));
    }

    @ApiOperation(value = "验证验证码")
    @GetMapping("/checkPhoneVerifyCode")
    @ResponseBody
    public Object checkPhoneVerifyCode(ModelMap modelMap, @RequestParam(name = "phone") String phone,@RequestParam(name = "code") String code) {
        return setSuccessModelMap(modelMap,appSmsService.checkPhoneVerifyCode(phone,code));
    }
}
